#include "headfile.h"

uint8 encoder_data[4] = {0x11,0x22,0x33,0x44};
vuint8 show_flag = 0;

int main(void)
{
    DisableGlobalIRQ();
    board_init();

    //System_Init();
    lcd_init();
    PWM_Init();
    Pid_Init_All();
//    gpio_init(B15, GPO, 1, GPIO_PIN_CONFIG);
    icm20602_init_spi();
    //seekfree_wireless_init();
    //timer_pit_interrupt_ms(TIMER_3, 5);
    gpio_init(B4, GPI, 1, IN_PULLUP);
//    gpio_init(A15, GPI, 1, IN_PULLUP);
//    gpio_init(B2, GPI, 1, IN_PULLUP);
//    gpio_init(D2, GPI, 1, IN_PULLUP);
    //ips114_showstr(0, 0, "master");

    uart_init(UART_3, 460800, UART3_TX_B10, UART3_RX_B11);
    uart_rx_irq(UART_3, ENABLE);
    nvic_init((IRQn_Type)(53 + UART_3), 0, 0, ENABLE);

    gpio_interrupt_init(C10, RISING, GPIO_INT_CONFIG);
    nvic_init(EXTI15_10_IRQn, 0, 1, ENABLE);


    //timer_pit_interrupt_ms(TIMER_2,5);
    // uart_putchar(UART_1, 0xdc);
    //mt9v03x_init();
    EnableGlobalIRQ(0);

    while (1)
    {
        //Motor_test();
//        GetAngleSpeedValue();
//
//        send_buff[0] = gyro_z_final;
//        send_buff[1] = gpyo_anglez_sum;
//        send_buff[2] = gpyo_anglez_sum_temp;
        //GetAngleSpeedValue();
        lcd_showint16(0, 0, error);
        
        //if (key1 == 0)
       // {
        //    systick_delay_ms(10);
         //   if (key1 == 0)
          //  {
                start_flag = 1;
                //gpio_toggle(B15);
         //   }
     //   }
                
//        if (show_flag == 1)
//        {
//            send_buff[0] = error;
//            vcan_sendware((uint8*)send_buff,sizeof(send_buff));
//            show_flag = 0;
//        }

        //vcan_sendware((uint8*)send_buff,sizeof(send_buff));
//        if (mt9v03x_finish_flag)
//        {
//            mt9v03x_finish_flag = 0;
//            err_deal();
//            gpio_toggle(B0);
//        }
    }
    return 0;
}



